//
//  ZMOrderAddressView.swift
//  zhonglibang
//
//  Created by Rowling on 2021/1/12.
//

import UIKit

class ZMOrderAddressView: ZMXIBView {
    
    @IBOutlet weak var nameText: UILabel!
    @IBOutlet weak var addressText: UILabel!
    @IBOutlet weak var nextView: UIImageView!
    @IBOutlet weak var userText: UILabel!
    
    var clickBlock : (()->())?
    
    var address : AddressModel? {
        didSet {
            if let address = address {
                nameText.text = address.area
                addressText.text = address.detail
                addressText.isHidden = false
                userText.isHidden = false
                userText.text = address.realName + " " + address.phone.zm.hidPhone()
            }
            else {
                nameText.text = "设置收货地址"
                addressText.isHidden = true
                userText.isHidden = true
            }
        }
    }

    override func awakeFromNib() {
        super.awakeFromNib()
        // 添加点击事件
        let tap = UITapGestureRecognizer(target: self, action: #selector(click))
        addGestureRecognizer(tap)
    }
    
    @objc func click() {
        if let clickBlock = clickBlock {
            clickBlock()
        }
    }
}

